package org.biblicalcontent.gbsbijbel.ui;

import java.util.Collections;
import java.util.List;

import org.biblicalcontent.gbsbijbel.IGbsBijbelService;
import org.biblicalcontent.gbsbijbel.model.IBijbel;
import org.biblicalcontent.gbsbijbel.model.ITestament;
import org.biblicalcontent.ui.generiek.NavigatorContentProvider;
import org.biblicalcontent.ui.generiek.ServiceProvider;

public class StatenvertalingContentProvider implements NavigatorContentProvider {

	private IGbsBijbelService bijbelService = ServiceProvider.getInstance().getService(IGbsBijbelService.class);

	public StatenvertalingContentProvider() {
		// doe niets.
	}

	@Override
	public Object getRootObject() {
		IBijbel bijbel = bijbelService.getBijbel();
		return bijbel;
	}

	@Override
	public List<?> getChildrenForParent(Object parent) {
		if (parent instanceof IBijbel) {
			return bijbelService.getTestamenten();
		} else if (parent instanceof ITestament) {
			return ((ITestament) parent).getBijbelboeken();
		}
		return Collections.emptyList();
	}

	@Override
	public boolean hasChildren(Object parent) {
		boolean hasChildren;
		if (parent == this) {
			hasChildren = true;
		} else {
			hasChildren = (parent instanceof IBijbel || parent instanceof ITestament);
		}
		return hasChildren;
	}

}
